package com.yzy.spring;

import com.yzy.common.User;
import org.springframework.beans.factory.FactoryBean;

/**
 * Description:
 * Date: 2020-06-03
 *
 * @author youzhiyong
 */
public class UserFactoryBean implements FactoryBean<User> {

    private User user;

    @Override
    public User getObject() throws Exception {
        if (user == null) {
            user = new User();
            user.setAge(10);
            user.setName("youzhiyong");
        }
        return user;
    }

    @Override
    public Class<?> getObjectType() {
        return user == null ? User.class : user.getClass();
    }

    @Override
    public boolean isSingleton() {
        return true;
    }
}
